<template>
	<view class="mainpadding2" style="padding-bottom: 150rpx;">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="titletext sanshier fonweight" style="color: #1ba95b;">{{item.name}}</view>
				<view class="xiaohong smalltext" v-if="item.is_reg==1">注册赠送</view>
			</view>
			<view class="margin_top flexleft">
				<u-icon name="hourglass-half-fill" color="#1ba95b" size="16"></u-icon>
				<view class="strongtext ershiba">{{item.days}}天</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext ershiba">满{{item.mj_price}}减{{item.price}}</view>
				<view class="flexright ">
					<!-- <view class="baibtn margin_right2" @click="delitem(item.id)">移除</view> -->
					<view class="lvbtn" @click="jumpurl('/pages_mypage/youhuiqtj?id=',item.id)">编辑</view>
				</view>
			</view>
		</view>
		<view class="gudingdb mainpadding">
			<view class="bigbtn" @click="jumpurltj('/pages_mypage/youhuiqtj')">添加优惠券</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
page: 1,
				limit: 12,
				list: {
					data: []
				},
				user_zbfapply_listid:""
			}
		},
		onLoad(options) {
			this.user_zbfapply_listid=options.user_zbfapply_listid
		},
		onShow() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					user_zbfapply_id:this.user_zbfapply_listid
				}
				let url = '/api/user/fbCoupon'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpurl(url, id) {
				uni.navigateTo({
					url: url + id+"&user_zbfapply_listid="+this.user_zbfapply_listid
				})
			},
			jumpurltj(url) {
				uni.navigateTo({
					url: url + "?user_zbfapply_listid="+this.user_zbfapply_listid
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #fafafa;
	}
</style>